//使用toast时可以传入参数，也可以不传入
/**
 * @description 消息提示框
 * @param {*} param0 
 */
const toast = ({
  title = "数据加载中...",
  icon = "none",
  duration = 2000,
  mask = true
} = {}) => {
  wx.showToast({
    title,
    icon,
    duration,
    mask
  })
}
/**
 * @description 模态对话框
 * @param {*} options 
 */
const modal = (options = {}) => {
  return new Promise((resolve) => {
    const defaultOpt = {
      title: '提示',
      content: '你确定执行该操作嘛？',
      confirmColor: "#f3514f"
    }

    const opts = Object.assign({}, defaultOpt, options)

    wx.showModal({
      ...opts,
      complete({
        confirm,
        cancel
      }) {
        confirm && resolve(true)
        cancel && resolve(false)
      }
    })
  })
}

wx.toast = toast
wx.modal = modal
export { toast,modal}